package xyz.xtt.asset.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.Max;
import lombok.extern.slf4j.Slf4j;
import xyz.xtt.asset.client.response.NftListVo;
import xyz.xtt.asset.service.IMyService;
import xyz.xtt.common.response.ApiResult;

/**
 * 我的
 * 
 * @author huqibo
 * @date 2025/03/24
 */
@Tag(name = "个人中心", description = "个人中心")
@Slf4j
@RequestMapping("/api/nft/asset")
@RestController
public class MyController {
	@Autowired
	private IMyService iMyService;

	@Operation(summary = "个人中心我的作品", description = "个人中心我的作品")
	@GetMapping("/my/getMyBuildNftList")
	public ApiResult<List<NftListVo>> getMyBuildNftList(@RequestHeader("uid") String uid,
			@RequestParam(value = "currPage", defaultValue = "1") Integer currPage, @RequestParam(value = "signUserId") String signUserId,
			@RequestParam(value = "pageSize", defaultValue = "10") @Max(value = 100, message = "每页数量不能超过100") Integer pageSize) {
		log.info("requestUri: /api/nft/asset/my/getMyBuildNftList requestParams: uid:{},cateGory:{},currPage:{},pageSize:{}", uid, currPage, pageSize);
		List<NftListVo> nftList = iMyService.getNftListByUidV2(StringUtils.hasText(signUserId) ? signUserId : uid, currPage, pageSize, "1", -1, 0);
		return ApiResult.ok(nftList);
	}

	@Operation(summary = "个人中心我的藏品", description = "个人中心我的藏口")
	@GetMapping("/my/getMyOwnNftList")
	public ApiResult<List<NftListVo>> getMyOwnNftList(@RequestHeader("uid") String uid, @RequestParam(value = "currPage", defaultValue = "1") Integer currPage,
			@RequestParam(value = "pageSize", defaultValue = "10") @Max(value = 100, message = "每页数量不能超过100") Integer pageSize) {
		log.info("requestUri: /api/nft/asset/my/getMyOwnNftLis requestParams: uid:{},cateGory:{},currPage:{},pageSize:{}", uid, currPage, pageSize);
		List<NftListVo> nftList = iMyService.getNftListByUidV2(uid, currPage, pageSize, "0", -1, 0);
		return ApiResult.ok(nftList);
	}

}
